package com.miniapp.web.controller.paicfti;

import com.miniapp.common.annotation.Anonymous;
import com.miniapp.common.annotation.Log;
import com.miniapp.common.core.controller.BaseController;
import com.miniapp.common.core.domain.AjaxResult;
import com.miniapp.common.core.page.TableDataInfo;
import com.miniapp.common.enums.BusinessType;
import com.miniapp.common.utils.SecurityUtils;
import com.miniapp.common.utils.poi.ExcelUtil;
import com.miniapp.core.domain.PaicFtiRateGen;
import com.miniapp.core.service.IPaicFtiRateGenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 平安货运险费率Controller
 *
 * @author ywd
 * @date 2024-11-29
 */
@RestController
@RequestMapping("/paic/rate")
public class PaicFtiRateGenController extends BaseController
{
    @Autowired
    private IPaicFtiRateGenService paicFtiRateGenService;

    /**
     * 查询平安货运险费率列表
     */

    @PreAuthorize("@ss.hasPermi('core:rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaicFtiRateGen paicFtiRateGen)
    {
        startPage();
        List<PaicFtiRateGen> list = paicFtiRateGenService.selectPaicFtiRateGenList(paicFtiRateGen);
        return getDataTable(list);
    }

    @Anonymous
    @GetMapping("/productList")
    public AjaxResult productList(PaicFtiRateGen paicFtiRateGen){
        List<PaicFtiRateGen> list = paicFtiRateGenService.selectPaicFtiRateGenList(paicFtiRateGen);
        return AjaxResult.success(list);
    }

    /**
     * 导出平安货运险费率列表
     */
    @PreAuthorize("@ss.hasPermi('core:rate:export')")
    @Log(title = "平安货运险费率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaicFtiRateGen paicFtiRateGen)
    {
        List<PaicFtiRateGen> list = paicFtiRateGenService.selectPaicFtiRateGenList(paicFtiRateGen);
        ExcelUtil<PaicFtiRateGen> util = new ExcelUtil<PaicFtiRateGen>(PaicFtiRateGen.class);
        util.exportExcel(response, list, "平安货运险费率数据");
    }

    /**
     * 获取平安货运险费率详细信息
     */
    @PreAuthorize("@ss.hasPermi('core:rate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paicFtiRateGenService.selectPaicFtiRateGenById(id));
    }

    /**
     * 新增平安货运险费率
     */
    @PreAuthorize("@ss.hasPermi('core:rate:add')")
    @Log(title = "平安货运险费率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaicFtiRateGen paicFtiRateGen)
    {
        return toAjax(paicFtiRateGenService.insertPaicFtiRateGen(paicFtiRateGen));
    }

    /**
     * 修改平安货运险费率
     */
    @PreAuthorize("@ss.hasPermi('core:rate:edit')")
    @Log(title = "平安货运险费率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaicFtiRateGen paicFtiRateGen)
    {
        return toAjax(paicFtiRateGenService.updatePaicFtiRateGen(paicFtiRateGen));
    }

    /**
     * 删除平安货运险费率
     */
    @PreAuthorize("@ss.hasPermi('core:rate:remove')")
    @Log(title = "平安货运险费率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paicFtiRateGenService.deletePaicFtiRateGenByIds(ids));
    }
}
